<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>事件委托的题目</title>
    <style>
    
        #wrapper {
            width: 50px;
            height: 50px;
            padding: 50px;
            background: #fff;
            border: 1px solid #ccc;
        }

        #inner {
            width: 50px;
            height: 50px;
            background: #f40;
        }

        #ipt {
            display: none;
        }
    </style>
</head>
<body>
    <!-- 点击wrapper 或者是 innner 会弹出 input 输入信息，点击空白区域input消息 鼠标划过显示刚刚的信息 -->
    
    <div id="wrapper">
        <div id="inner">

        </div>
    </div>
    <input type="text" id="ipt" placeholder="请输入信息">
    <script>
        
        let wrapper = document.getElementById('wrapper');
        let inner = document.getElementById('inner');
        let ipt = document.getElementById('ipt');

        wrapper.onclick = function (e) {
            var e = e || window.event;
            if (e.stopPropagation) {
                e.stopPropagation();
            } else {
                e.cancelBubble = true;
            }
            ipt.style.display = 'block';
            ipt.style.position = 'relative';

        }

        document.body.onclick = function (e) {
            var e = e || window.event;
            inner.title = ipt.value;
            if (e.target.id != 'ipt' && e.target.id != 'wrapper' && e.target.id != 'inner') {
                console.log(1);
                ipt.style.display = 'none';
            }  
        }



        
    
    </script>

</body>
</html>